/* eslint-disable no-continue */
import React from 'react';
import {
    StartSalaryCommLink,
    ApprovalLink,
    ReStartApprovalLink,
    NoticeLink,
    SalaryCommLink,
    HireNoticeOperate
} from './containers/StatusDetailLink';

export const backgroundTypeMap = {
    1: '同事评价',
    2: '第三方机构背调',
    3: '公开信息背调'
    // 99: '其他'
};

export const relateTypeMap = {
    1: '上级主管',
    2: '平级同事',
    3: '下属同事',
    4: '自定义'
};

export const recruitStatusInfo = [
    {
        value: 1,
        text: '待处理',
        color: '#ffa22d',
        background: 'rgba(255, 162, 45, 0.1)',
        link: params => <StartSalaryCommLink params={params} />
    },
    {
        value: 2,
        text: '需协商',
        color: '#ffa22d',
        background: 'rgba(255, 162, 45, 0.1)',
        link: params => <SalaryCommLink params={params} />
    },
    {
        value: 3,
        text: '审批中',
        color: '#5590f6',
        background: 'rgba(85, 144, 246, 0.1)',
        link: params => <ApprovalLink params={params} />
    },
    {
        value: 4,
        text: '审批拒绝',
        color: '#ffa22d',
        background: 'rgba(255, 162, 45, 0.1)',
        link: params => <ReStartApprovalLink params={params} />
    },
    {
        value: 5,
        text: '审批撤回',
        color: '#ffa22d',
        background: 'rgba(255, 162, 45, 0.1)',
        link: params => <ReStartApprovalLink params={params} />
    },
    {
        value: 6,
        text: '待接受',
        color: '#ffa22d',
        background: 'rgba(255, 162, 45, 0.1)',
        link: params => (
            <>
                <HireNoticeOperate {...params} size="16" style={{ marginRight: 10 }} />
                <NoticeLink params={params} />
            </>
        )
    },
    { value: 7, text: '已接受', color: '#44c69d', background: '#ecfff7', iconName: '', toolTipText: '' },
    {
        value: 8,
        text: '已拒绝',
        color: '#ffa22d',
        background: 'rgba(255, 162, 45, 0.1)',
        link: params => <NoticeLink params={params} />
    },
    {
        value: 9,
        text: '已入职',
        color: '#ffa22d',
        background: 'rgba(255, 162, 45, 0.1)',
        link: params => <NoticeLink params={params} />
    },
    {
        value: 10,
        text: '已淘汰',
        color: 'rgba(0,0,0,0.45)',
        background: 'rgba(0, 0, 0, 0.05)',
        link: () => {}
    },
    {
        value: 99,
        text: '其他',
        color: '#ffa22d',
        background: 'rgba(255, 162, 45, 0.1)',
        link: () => {}
    }
];

export const sendTypeMap = {
    1: '邮件',
    2: '其他'
};

export const contactWayMap = {
    1: '电话',
    2: '微信',
    3: 'QQ',
    4: '邮件',
    99: '其他'
};

export const objectContactTypeList = [
    { label: '手机', value: '1' },
    { label: '微信', value: '2' },
    { label: 'QQ', value: '3' },
    { label: '面谈', value: '4' }
];

export const objectContactTypeMap = objectContactTypeList.reduce((prev, curr) => {
    const newPrev = { ...prev };
    newPrev[curr.value] = curr.label;
    return newPrev;
}, {});

export const phoneAreaTextMap = {
    1: '+86',
    2: '+65'
};

export const feedbackStateInfo = [
    { text: '机构自主反馈', value: 0 },
    { text: '人事代填', value: 1 }
];

const arrayCHNNum = ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
const arrayCHNBit = ['', '十', '百', '千'];

export function changeNumToCharacter(s_) {
    const numArray = s_.toString().split('');
    if (numArray.length === 2 && numArray[0] === '1') {
        numArray[0] = 'y';
    }
    for (let i = numArray.length - 1; i >= 0; i -= 1) {
        if (numArray[i] === '0') {
            numArray[i] = 'x';
        } else {
            break;
        }
    }
    let result = '';
    let bLast0 = false;
    for (let i = 0; i < numArray.length; i += 1) {
        if (numArray[i] === 'x') {
            continue;
        }
        if (numArray[i] === '0' && bLast0) {
            bLast0 = true;
            continue;
        }
        if (numArray[i] !== 'y') {
            // delete 1 in ten
            result += arrayCHNNum[parseInt(numArray[i], 10)];
        }
        if (numArray[i] === '0') {
            bLast0 = true;
            continue;
        }
        bLast0 = false;

        result += arrayCHNBit[numArray.length - i - 1];
    }
    // console.log(result);
    return result;
}
